<?php
namespace Admin\Controller;

class CookbookController extends CommonController{
    
    public function _before_index(){
        //分类数组
        $cateRow = D('Resource')->getResByType('cookbook');
        $cateRow[0] = '健康食谱';
        $this->assign('cateRow',$cateRow);
    }
    
    public function edit(){
        if(IS_POST){
            $res = D($this->controller)->saveData(I('post.'));
            $res ? die('suc') : die('err');
        }else{
            $id=I('get.id');
            if($id){
                $this->assign('vo',D($this->controller)->find($id));
            }
            $this->assign('upPageUrl',$_SERVER['HTTP_REFERER']);
            $this->assign('cateArr',M('Resource')->where(array('type'=>'cookbook'))->order('id asc')->select());//食物百科
            $this->display();
        }
    }
    
}